package _07反射获取任意权限的Constructor;

import com.asin.domain.Person;

import java.lang.reflect.Constructor;

public class Demo {
    public static void main(String[] args) throws NoSuchMethodException {
        Class<Person> personClass = Person.class;
        //获取任意权限的构造方法数组
        Constructor<?>[] declaredConstructors = personClass.getDeclaredConstructors();
        for (Constructor<?> declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }

        //获取任意权限的单个构造方法
        Constructor<Person> declaredConstructor = personClass.getDeclaredConstructor(int.class);
        System.out.println(declaredConstructor);//protected com.asin.domain.Person(int)

    }
}
